package xyz.zyt123.hikvideo.common;

import lombok.Getter;
import lombok.Setter;

/**
 * @author zhuyuntao
 */
@Setter
@Getter
public class AjaxResult<T> {
  // 2000 success, 2001 fail
  private int code;
  private String msg;
  private T data;

  public static <T> AjaxResult<T> success(T data) {
    AjaxResult<T> tAjaxResult = new AjaxResult<>();
    tAjaxResult.setCode(2000);
    tAjaxResult.setData(data);
    return tAjaxResult;
  }

  public static <T> AjaxResult<T> success() {
    AjaxResult<T> tAjaxResult = new AjaxResult<>();
    tAjaxResult.setCode(2000);
    return tAjaxResult;
  }

  public static <T> AjaxResult<T> fail(String msg) {
    AjaxResult<T> tAjaxResult = new AjaxResult<>();
    tAjaxResult.setCode(2001);
    tAjaxResult.setMsg(msg);
    return tAjaxResult;
  }
  public static <T> AjaxResult<T> authentication(String msg) {
    AjaxResult<T> tAjaxResult = new AjaxResult<>();
    tAjaxResult.setCode(40001);
    tAjaxResult.setMsg(msg);
    return tAjaxResult;
  }
}
